(function(){
var TARGET_CHAR = ["。","，",".",",","；",";","!","！","\n"];
	var SW = [["什么","神马"],["你妈","尼玛"],["没有","木有"],["怎么","肿么"],["我","劳资"],["我们","劳资"]]
function randomShot(s, min, max) {
    var range = Math.floor(Math.random()*(max - min)) + min;
    var result = "";
    for (var i = 0; i < range ; i++) {
        result += s;
    }
    return result;
}

function makeFun(source) {
    source.replace(/^\s+|\s+$/g, "");
    if (Math.random() * 10 < 1) {
        var target = Math.floor(Math.random() * source.length);
        source = source.substring(0, target) + "泥马" + source.substring(target, source.length);
    } else if (Math.random() * 10 < 2) {
        source = "尼玛" + source;
    }
    if (Math.random()*10 < 1) {
        source += randomShot("啊", 1, 5);
    }
    if (Math.random()*10 < 3) {
        source += "有木有" + randomShot("！", 3, 6);
        if (Math.random()*10 < 3) {
            source += "亲" + randomShot("！", 3, 6);
        }
    }
    for (var i = SW.length; i--;) {
        var old = SW[i][0];
        var _new = SW[i][1];
        source = source.replace(old, _new);
    }
    source += randomShot("！", 3, 10);
    return source;	
}

function process(source) {
    var l = [];
    var p = 0;
    for (var i = 0; i < source.length; i++ ){
        if (TARGET_CHAR.indexOf(source.charAt(i)) != -1) {
            if ((i-p) > 5 || i == source.length -1) {
                var s = source.substring(p, i);
                if (p != 0) {
                    s = s.substring(1, s.length);
                }
                p = i;
                l.push(makeFun(s));
            }
        }
    }
    if (p < source.length - 1) {
        source = source.substring(p, source.length);
        if (p != 0) {
            source = source.substring(1, source.length);
        }
        source = makeFun(source.replace(/^\s+|\s+$/g, ""));
        l.push(source);
    }
    l[l.length - 1] += randomShot("！", 5, 10);	
    return l;
}

paoxiao = function(s){
    return process(s).join("");
}
})();
